package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC944 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int minDeletionSize(String[] strs) {
            int m = strs.length, n = strs[0].length(), ans = 0;
            for (int i = 0; i < n; i++) {
                char cur = strs[0].charAt(i);
                for (int j = 1; j < m; j++) {
                    if (strs[j].charAt(i) < cur) {
                        ans++;
                        break;
                    }
                    cur = strs[j].charAt(i);
                }
            }

            return ans;
        }
    }

    public void run() {
        System.out.println(new Solution().minDeletionSize(new String[]{"cba", "daf", "ghi"}));
        System.out.println(new Solution().minDeletionSize(new String[]{"a", "b"}));
        System.out.println(new Solution().minDeletionSize(new String[]{"zyx", "wvu", "tsr"}));
        System.out.println(new Solution().minDeletionSize(new String[]{"rrjk", "furt", "guzm"}));
    }

    public static void main(String[] args) throws Exception {
        LC944 an = new LC944();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
